package cn.DesignModel.Responsibility;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class Demo {
    //这是一个main方法,是程序的入口
    public static void main(String[] args) {
        Msg msg = new Msg();
        msg.setMsg("我喜欢<font color='red'>体育、代码、美食、美女等</font>");
        FirstFilter firstFilter = new FirstFilter();
        SecondFilter secondFilter = new SecondFilter();
        ThirdFilter thirdFilter = new ThirdFilter();
        FourthFilter fourthFilter = new FourthFilter();

        //下面是ChainFilter，两个过滤器链条
        ChainFilter chainFilter1 = new ChainFilter();
        ChainFilter chainFilter2 = new ChainFilter();

        chainFilter1.add(firstFilter).add(secondFilter);
        chainFilter2.add(thirdFilter).add(fourthFilter);

        //把过滤器链2放入过滤器链1, 方便以后
        chainFilter1.add(chainFilter2);

        //最终的情况是过滤器链2有4个过滤器，然后再遍历过滤器的时候调用过滤方法
        chainFilter1.doFilter(msg);

        System.out.println(msg.getMsg());

    }
}
